<?php
/**
 * woodranch functions and definitions
 *
 * @package woodranch
 */

/**
 * Set the content width based on the theme's design and stylesheet.
 */
require_once 'vafpress/bootstrap.php';
require_once 'admin/data_sources.php'; 

if ( ! isset( $content_width ) ) {
	$content_width = 640; /* pixels */
}

if ( ! function_exists( 'woodranch_setup' ) ) :
/**
 * Sets up theme defaults and registers support for various WordPress features.
 *
 * Note that this function is hooked into the after_setup_theme hook, which
 * runs before the init hook. The init hook is too late for some features, such
 * as indicating support for post thumbnails.
 */

function woodranch_setup() {

	/*
	 * Make theme available for translation.
	 * Translations can be filed in the /languages/ directory.
	 * If you're building a theme based on woodranch, use a find and replace
	 * to change 'woodranch' to the name of your theme in all the template files
	 */
	load_theme_textdomain( 'woodranch', get_template_directory() . '/languages' );

	// Add default posts and comments RSS feed links to head.
	add_theme_support( 'automatic-feed-links' );

	/*
	 * Enable support for Post Thumbnails on posts and pages.
	 *
	 * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
	 */
	add_theme_support( 'post-thumbnails' );

	// This theme uses wp_nav_menu() in one location.
	register_nav_menus( array(
		'primary' => __( 'Primary Menu', 'woodranch' ),
		'secondary' => __( 'Footer Menu', 'woodranch' ),
	) );
	//themes customizer
	function themeslug_theme_customizer( $wp_customize ) {
		$wp_customize->add_section( 'themeslug_logo_section' , array(
			'title'       => __( 'Logo', 'themeslug' ),
			'priority'    => 30,
			'description' => 'Upload a logo to replace the default site name and description in the header',
		) );
		$wp_customize->add_setting( 'themeslug_logo' );
		$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'themeslug_logo', array(
			'label'    => __( 'Logo', 'themeslug' ),
			'section'  => 'themeslug_logo_section',
			'settings' => 'themeslug_logo',
		) ) );
	}
	add_action('customize_register', 'themeslug_theme_customizer');
	// Enable support for Post Formats.
	//add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) );

	// Setup the WordPress core custom background feature.
	//add_theme_support( 'custom-background', apply_filters( 'woodranch_custom_background_args', array(
		//'default-color' => 'ffffff',
		//'default-image' => '',
	//) ) );
}
endif; // woodranch_setup
add_action( 'after_setup_theme', 'woodranch_setup' );

/**
 * Register widgetized area and update sidebar with default widgets.
 */
function woodranch_widgets_init() {
	register_sidebar( array(
		'name'          => __( 'Sidebar', 'woodranch' ),
		'id'            => 'sidebar-1',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h1 class="widget-title">',
		'after_title'   => '</h1>',
	) );
	register_sidebar( array(
		'name'          => __( 'Sidebar Footer One', 'woodranch' ),
		'id'            => 'sidebar-footer-one',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h6 class="widget-title">',
		'after_title'   => '</h6>',
	) );
	register_sidebar( array(
		'name'          => __( 'Sidebar Footer Two', 'woodranch' ),
		'id'            => 'sidebar-footer-two',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h6 class="widget-title">',
		'after_title'   => '</h6>',
	) );
	register_sidebar( array(
		'name'          => __( 'Sidebar Footer Three', 'woodranch' ),
		'id'            => 'sidebar-footer-three',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h6 class="widget-title">',
		'after_title'   => '</h6>',
	) );
	register_sidebar( array(
		'name'          => __( 'Sidebar Footer Four', 'woodranch' ),
		'id'            => 'sidebar-footer-four',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h6 class="widget-title">',
		'after_title'   => '</h6>',
	) );
}
add_action( 'widgets_init', 'woodranch_widgets_init' );

/**
 * Enqueue scripts and styles.
 */
function woodranch_scripts() {
	wp_enqueue_style( 'woodranch-style', get_stylesheet_uri() );
	wp_register_style( 'skeleton-grid', get_template_directory_uri() . '/css/skeleton-12col.css');
    wp_enqueue_style( 'skeleton-grid' );
	
	//wp_enqueue_script( 'woodranch-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true );

	wp_enqueue_script( 'woodranch-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );

	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
		wp_enqueue_script( 'comment-reply' );
	}
}
add_action( 'wp_enqueue_scripts', 'woodranch_scripts' );

// options
$tmpl_opt = get_template_directory() . '/admin/option/option.php';

/**
* Create instance of Options
*/
$theme_options = new VP_Option(array(
        'is_dev_mode' => false, // dev mode, default to false
        'option_key' => 'vpt_option', // options key in db, required
        'page_slug' => 'vpt_option', // options page slug, required
        'template' => $tmpl_opt, // template file path or array, required
        'menu_page' => 'themes.php', // parent menu slug or supply `array` (can contains 'icon_url' & 'position') for top level menu
        'use_auto_group_naming' => true, // default to true
        'use_util_menu' => true, // default to true, shows utility menu
        'minimum_role' => 'edit_theme_options', // default to 'edit_theme_options'
        'layout' => 'fixed', // fluid or fixed, default to fixed
        'page_title' => __( 'Theme Options', 'vp_textdomain' ), // page title
        'menu_label' => __( 'Theme Options', 'vp_textdomain' ), // menu label
));

function my_option( $name )
{
	return vp_option( "vpt_option." . $name );
}
/**
 * Implement the Custom Header feature.
 */
//require get_template_directory() . '/inc/custom-header.php';

/**
 * Custom template tags for this theme.
 */
require get_template_directory() . '/inc/template-tags.php';

/**
 * Custom functions that act independently of the theme templates.
 */
require get_template_directory() . '/inc/extras.php';

/**
 * Customizer additions.
 */
require get_template_directory() . '/inc/customizer.php';

/**
 * Load Jetpack compatibility file.
 */
require get_template_directory() . '/inc/jetpack.php';

/**
 * Load Breadcumb file.
 */

require get_template_directory() . '/inc/breadcumb-tags.php';

function custom_contact_js(){
	wp_enqueue_script('custom-js',get_bloginfo('template_url').'/js/custom.js');	
}
add_action('wp_enqueue_scripts','custom_contact_js');

function my_custom_scripts() {
if ( is_page_template('page-templates/contact-page.php') ){
	wp_register_script( 'my-ui-jsi', get_stylesheet_directory_uri().'/js/contact_js/jquery-1.9.1.js');
	wp_register_script( 'my-ui-js', get_stylesheet_directory_uri().'/js/contact_js/jquery-ui.js');
	wp_register_style( 'my-date-css', get_stylesheet_directory_uri().'/css/jquery-ui.css');
	wp_enqueue_script( 'my-ui-jsi' );
	wp_enqueue_script( 'my-ui-js' );
	wp_enqueue_style( 'my-date-css' );
	wp_register_script( 'jjquery-js', get_stylesheet_directory_uri(). '/js/contact_js/jquery.min.js');
	wp_register_script( 'validate-js', get_stylesheet_directory_uri(). '/js/contact_js/jQuery.Validate.min.js');
	
	wp_enqueue_script( 'jjquery-js' );
	wp_enqueue_script( 'validate-js' );
	
	}
	
}

add_action( 'wp_enqueue_scripts', 'my_custom_scripts' );	